home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagn_r.zip / RECORDS.SWG / 0010_Another Delete Routine.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-27  |  842b  |  34 lines

  1. {
  2. STEVE ROGERS
  3.  
  4. >A method that I have successfully used to delete Records in place is to...
  5.  
  6.   'Scuse me For butting in, but I have another approach which will
  7.   preserve your Record order. I will present it For a File of Records
  8.   the total size of which is less than 64K. The routine may easily be
  9.   adapted For large Files:
  10. }
  11.  
  12. Procedure del_rec(fname : String; target : LongInt; rec_size : LongInt);
  13. Type
  14.   t_buf = Array[1..65520] of Byte;
  15. Var
  16.   f   : File;
  17.   buf : ^t_buf;
  18.   n   : Word;
  19. begin
  20.   new(buf);
  21.   assign(f, fname);  { open your File }
  22.   reset(f, 1);
  23.   blockread(f, buf^, sizeof(buf^), n);
  24.   close(f);
  25.  
  26.   move(buf^[succ(target) * rec_size],
  27.        buf^[target * rec_size], n - (target * rec_size));
  28.   dec(n, rec_size);
  29.   reWrite(f, 1);
  30.   blockWrite(f, buf^, n);
  31.   close(f);
  32.   dispose(buf);
  33. end;
  34.